#!/usr/bin/env bash

image=docker.dm-ai.cn/algorithm-research/calligraphy/py3.8-cuda11.0-cudnn8-trt8.4-torch1.7:v2
#image=docker.dm-ai.cn/algorithm-research/py38-cuda11.2-cudnn8.1-ubuntu18.04:torch1.8.1-trt8.4
#sudo docker run -it --gpus all -p 40000:80 -v `pwd`:/app $image /bin/bash

############### 将容器转换为镜像 ###############
# docker commit -m "info" -a "author" container_id image_id:tag
# docker push image_id:tag

############### 一些异常处理    ###############
# Error response from daemon: could not select device driver "" with capabilities: [[gpu]]
# 解决方法：https://zhuanlan.zhihu.com/p/373493938?utm_id=0
# pip安装：pip install --no-cache-dir opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple

############### docker清除垃圾 ###############
# apt-get autoclean
# apt-get clean
# apt-get autoremove
# rm -rf ~/.cache
# pip cache purge # 清除 pip 缓存中的所有文件。

############### 通过Dockerfile构建docker ###############
#TODO 可以添加--name $name 指定容器别名
#image="docker.dm-ai.cn/algorithm-research/py38-cuda11.2-cudnn8.1-ubuntu18.04:latest"
#image="docker.dm-ai.cn/algorithm-research/llama2-chinese:latest"
image="docker.dm-ai.cn/algorithm-research/panjinquan/py3.10-cuda11.7-cudnn8.5-torch2.0:llm"
image="docker.dm-ai.cn/algorithm-research/panjinquan/py3.10-cuda11.7-cudnn8.5-torch2.0:llm-v2"
image="docker.dm-ai.cn/algorithm-research/panjinquan/py3.10-cuda11.7-cudnn8.5-torch2.0:llm-v2.1"
image="docker.dm-ai.cn/algorithm-research/panjinquan/py3.10-cuda11.7-cudnn8.5-torch2.0:llm-gradio"
#docker build -t=$image .
#docker run -it --gpus all -p 7860:7860 -v `pwd`:/app $image /bin/bash
docker run -it --gpus all -p 7860:7860 --ulimit memlock=-1 --ulimit stack=67108864 --memory-swap=-1 --memory=256G --runtime=nvidia --ipc host --privileged --network host  -v `pwd`:/app $image /bin/bash

############### 通过Dockerfile构建docker ###############
#image=docker.dm-ai.cn/algorithm-research/calligraphy/py3.8-cuda11.0-cudnn8-trt8.4-torch1.7:v2
#image=flagalpha/llama2-chinese-7b:gradio
#image=docker.dm-ai.cn/algorithm-research/zhanjie/vllm-3090:v1
#image=docker.dm-ai.cn/algorithm-research/panjinquan/py3.9-cuda11.7-cudnn8.5-torch2.0:v1
#docker build -f docker/Dockerfile -t flagalpha/llama2-chinese-7b:gradio .
#docker run -it --gpus all -p 80:80 -v `pwd`:/app $image /bin/bash
